package com.liaoban.app.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.liaoban.app.R;
import com.liaoban.app.api.type.Earn;
import com.liaoban.app.util.DateTimeUtils;

import java.util.List;

/**
 * Created by ybc on 2018/7/13 0013.
 * 我的收益
 */
public class EarnListAdapter extends BaseQuickAdapter<Earn, BaseViewHolder> {

    public EarnListAdapter(@Nullable List<Earn> data) {
        super(R.layout.item_earn, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Earn item) {
        helper.setText(R.id.tv_description, item.getDescription());
        helper.setText(R.id.tv_time, DateTimeUtils.formatData(item.getTime() * 1000L, "yyyy-MM-dd HH:mm:ss"));
        helper.setText(R.id.tv_money, item.getMoney());
        try {
            double moneyD = Double.parseDouble(item.getMoney().trim());
            if (moneyD >= 0) {
                helper.setTextColor(R.id.tv_money, mContext.getResources().getColor(R.color.btn_red));
            } else {
                helper.setTextColor(R.id.tv_money, mContext.getResources().getColor(R.color.black));
            }
        } catch (Exception e) {
        }

    }
}
